package com.silence.springboot.controller;

import com.mybatisflex.core.paginate.Page;
import com.silence.springboot.common.Result;
import com.silence.springboot.service.ConfirmDiagnosisInfoService;
import com.silence.springboot.vo.input.PageConfirmDiagnosisInfoInput;
import com.silence.springboot.vo.input.SaveConfirmDiagnosisInfoInput;
import com.silence.springboot.vo.input.WarningStudentInput;
import com.silence.springboot.vo.output.PageConfirmDiagnosisInfoOutput;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 确诊记录表 控制层。
 *
 * @author mybatis-flex-helper automatic generation
 * @since 1.0
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@Tag(name = "确诊记录表控制层")
@RequestMapping("/confirmDiagnosisInfo")
public class ConfirmDiagnosisInfoController {

    /**
     * 确诊记录表
     */
    private final ConfirmDiagnosisInfoService confirmDiagnosisInfoService;

    /**
     * 分页查询
     *
     * @param input 入参
     * @return 分页查询
     */
    @PostMapping("/pageInfo")
    @Operation(summary = "分页查询", description = "分页查询")
    public Result<Page<PageConfirmDiagnosisInfoOutput>> pageInfo(@RequestBody PageConfirmDiagnosisInfoInput input) {
        // 返回成功
        return Result.success(confirmDiagnosisInfoService.pageInfo(input));
    }

    /**
     * 风险预警
     *
     * @param input 入参
     * @return 风险预警
     */
    @PostMapping("/warningStudent")
    @Operation(summary = "风险预警", description = "风险预警")
    public Result<Void> warningStudent(@Validated @RequestBody WarningStudentInput input) {
        confirmDiagnosisInfoService.warningStudent(input);
        // 返回成功
        return Result.success();
    }

    /**
     * 保存确诊信息
     *
     * @param input 入参
     * @return 保存确诊信息
     */
    @PostMapping("/saveInfo")
    @Operation(summary = "保存确诊信息", description = "保存确诊信息")
    public Result<Void> saveInfo(@RequestBody SaveConfirmDiagnosisInfoInput input) {
        confirmDiagnosisInfoService.saveInfo(input);
        // 返回成功
        return Result.success();
    }

    /**
     * 检查学生是否预警
     *
     * @param studentNumber 学生编号
     * @return 检查学生是否预警
     */
    @GetMapping("/checkStudentIsWarning/{studentNumber}")
    @Operation(summary = "检查学生是否预警", description = "检查学生是否预警")
    public Result<Boolean> checkStudentIsWarning(@PathVariable String studentNumber) {
        return Result.success(confirmDiagnosisInfoService.checkStudentIsWarning(studentNumber));
    }

}